/*
 * Copyright 2011 Andreas Bolt abo@abosoft.us
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

#include <QtGui>
#include <QMessageBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>

#include "mainwindow.h"
#include "aboutdlg.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{

    createActions ();
    createMenus ();



// create main widget
    mainWidget = new QWidget ();
    QVBoxLayout *vbox = new QVBoxLayout ();

    // download table
    downloadTable = new QTableWidget ();
    vbox->addWidget(downloadTable);


    mainWidget->setLayout(vbox);
    setCentralWidget (mainWidget);
}

void MainWindow::createActions ()
{
// Quit action
    quitAct = new QAction (QIcon(":/icons/32x32/quit.png"), tr("&Quit"), this);
    quitAct->setStatusTip(tr("Quit the application"));
    quitAct->setShortcut(QKeySequence::Quit);
    connect (quitAct, SIGNAL(triggered()), this, SLOT(close()));

// Info
    aboutAct = new QAction (QIcon(":/icons/32x32/info.png"), tr("&About"), this);
    aboutAct->setStatusTip(tr("Information about this application"));
    connect (aboutAct, SIGNAL(triggered()), this, SLOT(about ()));

// Info Qt
    aboutQtAct = new QAction (QIcon(":/icons/32x32/qt.png"), tr("About Q&t"), this);
    aboutQtAct->setStatusTip(tr("Information about Qt"));
    connect (aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));
}

void MainWindow::createMenus ()
{

    fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addSeparator();
    fileMenu->addAction(quitAct);

    helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(aboutAct);
    helpMenu->addAction(aboutQtAct);
}






// SLOTS

void MainWindow::about ()
{
    AboutDlg dlg;

    dlg.exec();
}

void MainWindow::aboutQt ()
{
    QMessageBox::aboutQt(this);
}
